<?php

use yii\db\Migration;

class m170302_033034_alter_orders_items extends Migration
{
    private function createDbs(){
        $dbs = [];
        $dbs_info =\Yii::$app->params['db'];
        foreach($dbs_info as $k=>$v){
            $dbs[$k] = \Yii::createObject($v);
        }
        return $dbs;
    }


    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
        $dbs = $this->createDbs();
        foreach($dbs as $v) {
            $this->db = $v;
            $this->addColumn('{{%orders_items}}', 'group_id',  $this->integer().' default 0 comment \'组合商品id\'');
        }
    }

    public function safeDown()
    {
        $dbs = $this->createDbs();
        foreach($dbs as $v) {
            $this->db = $v;
            $this->dropColumn('{{%orders_items}}', 'group_id');
        }
    }
}
